<script>
import {getToken} from "@/utils/auth";

export default {
  name: "exportClass",
  data() {
    return {
      dialogVisible: false,
      headers: {
        Authorization: "Bearer " + getToken(), //headers属性中添加token，这个属性是el-upload自带的用来设置上传请求头部
      },
    };
  },
}
</script>

<template>
  <div>
    <!--    导入-->
    <div class="input">
      <el-button type="primary" @click="dialogVisible = true">导入</el-button>
      <el-dialog
        :center="true"
        :visible.sync="dialogVisible"
        title="班级导入"
        width="30%">
        <el-upload
          :headers="headers"
          action="http://1.117.81.216:8086/stage-api/student/class/import"
          class="upload-demo"
          drag
          multiple>
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
          <div slot="tip" class="el-upload__tip" style="margin-left: 50px">仅允许导入xls、xlsx格式文件。
            <a
              download
              href="/班级导入模板.xlsx"
              style="color: #00afff">下载模板</a>
          </div>
        </el-upload>
      </el-dialog>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.input {
  .upload-demo {
    margin-left: 25px;
  }
}
</style>
